package cn.edu.zut.project1.mapper;

import cn.edu.zut.project1.pojo.Message;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper {

    // 插入消息（系统/用户消息通用）
    @Insert("insert into message (" +
            "sender_id, receiver_id, order_id, content, type, is_read, create_time" +
            ") values (" +
            "#{senderId}, #{receiverId}, #{orderId}, #{content}, #{type}, #{isRead}, #{createTime}" +
            ")")
    int insert(Message message);

    // 查订单的所有消息
    @Select("select * from message where order_no = #{orderNo} order by create_time desc")
    List<Message> selectByOrderNo(String orderNo);
}
